<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>cube</title>
    <style>
        /* 对于舞台元素*/
        .rect-wrap {
            position: relative;
            perspective: 1600px;
        }
        /*对于容器*/
        .container {
            width: 800px;
            height: 800px;
            transform-style: preserve-3d;
            transform-origin: 50% 50% 200px; /*设置3d空间的原点在平面中心再向Z轴移动200px的位置*/
        }
        /*立方体的每个面*/
        .slide {
            width: 400px;
            height: 400px;
            position: absolute;
        }
        /*立方体顶面*/
        .top {
            left: 200px;
            top: -200px;
            transform: rotateX(-90deg);
            transform-origin: bottom;
            background: #f00;
        }
        /*立方体底面*/
        .bottom {
            left: 200px;
            bottom: -200px;
            transform: rotateX(90deg);
            transform-origin: top;
            background: #ff0;
        }
        /*立方体左面*/
        .left{
            left: -200px;
            top: 200px;
            transform: rotateY(90deg);
            transform-origin: right;
            background: #f0f;
        }
        /*立方体右面*/
        .right{
            left: 600px;
            top: 200px;
            transform: rotateY(-90deg);
            transform-origin: left;
            background: #0ff;
        }
        /*立方体前面*/
        .front{
            left: 200px;
            top: 200px;
            transform: translateZ(400px);
            background: #0f0;
        }
        /*立方体后面*/
        .back{
            left: 200px;
            top: 200px;
            transform: translateZ(0);
            background: #00f;
        }
        @keyframes rotate-frame {
            0% {
                transform: rotateX(0deg) rotateY(0deg);
            }
            10% {
                transform: rotateX(0deg) rotateY(180deg);
            }
            20% {
                transform: rotateX(-180deg) rotateY(180deg);
            }
            30% {
                transform: rotateX(-360deg) rotateY(180deg);
            }
            40% {
                transform: rotateX(-360deg) rotateY(360deg);
            }
            50% {
                transform: rotateX(-180deg) rotateY(360deg);
            }
            60% {
                transform: rotateX(90deg) rotateY(180deg);
            }
            70% {
                transform: rotateX(0) rotateY(180deg);
            }
            80% {
                transform: rotateX(90deg) rotateY(90deg);
            }
            90% {
                transform: rotateX(90deg) rotateY(0);
            }
            100% {
                transform: rotateX(0) rotateY(0);
            }
        }
        .container{
            animation: rotate-frame 30s linear infinite;
        }
    </style>
</head>
<body>
<div class="rect-wrap">   <!--舞台元素，设置perspective，让其子元素获得透视效果。-->
    <div class="container">    <!--容器，设置transform-style: preserve-3d，让其子元素在3D空间呈现-->
        <div class="top slide">top</div>   <!--立方体的六个面-->
        <div class="bottom slide">bottom</div>
        <div class="left slide">left</div>
        <div class="right slide">right</div>
        <div class="front slide">front</div>
        <div class="back slide">back</div>
    </div>
</div>



</body>
</html>